import request from 'umi-request';

// 获取学生课程
export const getStudentCourse = async (data: any) => {
    return request<any>('/course/student', {
        method: 'GET',
        params: { studentId: data },
    });
};

// 根据课程获取学生测验
export const getStudentTest = async (data: any) => {
    return request<any>('/test/student', {
        method: 'GET',
        params: { courseId: data },
    });
};

// 根据测验下的题目
export const getTestQuestion = async (data: any) => {
    return request<any>('/questions/test/student', {
        method: 'GET',
        params: { testId: data },
    });
};

// 提交问卷答案
export const addResult = async (data: any) => {
    return request<any>('/result/add', {
        method: 'POST',
        data,
        // headers: {
        //     'Content-Type': 'application/json'
        // }
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
};


// 获取测验成绩
export const getScore = async (studentId: any, testId: any) => {
    return request<any>('/score', {
        method: 'GET',
        params: { studentId, testId },
    });
};

// 获取答案，就是说要自己过滤有点离谱
export const getAnswer = async (data: any) => {
    return request<any>('/questions/test/answer', {
        method: 'GET',
        params: { testId: data },
    });
};

// 删除题目
export const deleteQuestion = async (data: any) => {
    return request<any>('/test/questions/delete', {
        method: 'POST',
        data,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
};